import request from "@/utils/request";
import { AxiosPromise } from "axios";
import {
  OrderQuery,
  OrderPageVO,
  OrderItemQuery,
  OrderItemPageVO,
  OrderTotalDto,
  OrderTotalVO,
  OrderCategoryTotalDto,
  OrderCategoryTotalVO,
} from "./types";

/**
 * 订单分页列表
 */
export function getPage(queryParams: OrderQuery): AxiosPromise<OrderPageVO> {
  return request({
    url: "/api/v1/order/page",
    method: "get",
    params: queryParams,
  });
}

export function getItemPage(
  queryItemParams: OrderItemQuery
): AxiosPromise<OrderItemPageVO> {
  return request({
    url: "/api/v1/order/item/page",
    method: "get",
    params: queryItemParams,
  });
}

// 商品总订单
export function getTotalOrder(
  orderTotalDto: OrderTotalDto // 查询条件
): AxiosPromise<OrderTotalVO> {
  return request({
    url: "/api/v1/order/total",
    method: "get",
    params: orderTotalDto,
  });
}

// 商品分类订单
export function getCategoryTotalOrder(
  orderCategoryTotalDto: OrderCategoryTotalDto // 查询条件
): AxiosPromise<OrderCategoryTotalVO> {
  return request({
    url: "/api/v1/order/category/total",
    method: "get",
    params: orderCategoryTotalDto,
  });
}

/**
 * 订单总数（按时间）
 */
export function getOrderTotalByTime(type: any): AxiosPromise {
  return request({
    url: "/api/v1/order/total/statistics",
    method: "get",
    params: {
      type,
    },
  });
}
